//
//  Material_hhhh_Cell.m
//  Food
//
//  Created by dllo on 15/7/18.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "Material_hhhh_Cell.h"
#import "BaseHeader.h"
@implementation Material_hhhh_Cell

-(void)dealloc
{
    [_rawMaterialimage release];
    [_rawMaterialLable release];
    [_seasoningLable release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.rawMaterialtitle = [[UILabel alloc] init];
        [self.rawMaterialtitle setFont:[UIFont systemFontOfSize:15]];
        self.rawMaterialtitle.text = @"原料:";
        
        [self.contentView addSubview:self.rawMaterialtitle];
        
        self.rawMaterialimage = [[UIImageView alloc] init];
        
        [self.contentView addSubview:self.rawMaterialimage];
        
        self.rawMaterialLable = [[UILabel alloc] init];
        [self.rawMaterialLable setFont:[UIFont systemFontOfSize:13]];
        self.rawMaterialLable.numberOfLines = 0;
        [self.contentView addSubview:self.rawMaterialLable];
        
        
        self.seasoningtitle = [[UILabel alloc] init];
         [self.seasoningtitle setFont:[UIFont systemFontOfSize:15]];
        self.seasoningtitle.text = @"调料:";
        
        [self.contentView addSubview:self.seasoningtitle];
        
        self.seasoningLable = [[UILabel alloc] init];
        self.seasoningLable.numberOfLines = 0;
        [self.seasoningLable setFont:[UIFont systemFontOfSize:13]];
        [self.contentView addSubview:self.seasoningLable];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.rawMaterialtitle.frame = CGRectMake(20, 0, 40, 30);
    self.rawMaterialLable.frame = CGRectMake(20, 30, ScreenWidth - 40, 50);
    self.rawMaterialimage.frame = CGRectMake(20, self.rawMaterialLable.frame.size.height + 30, ScreenWidth - 40, 180);
    self.seasoningtitle.frame = CGRectMake(20, self.rawMaterialimage.frame.origin.y + self.rawMaterialimage.frame.size.height, ScreenWidth - 40, 30);
    self.seasoningLable.frame = CGRectMake(20, self.rawMaterialimage.frame.origin.y + self.rawMaterialimage.frame.size.height + 30, ScreenWidth - 40 , 50);
}

- (void)setModel:(HomePage_Material_model *)model
{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    self.rawMaterialLable.text = model.fittingRestriction;
    self.seasoningLable.text = model.method;
}

+ (CGFloat) heightwithText:(NSString *) text
{
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:13]};
    CGSize size = CGSizeMake(375 - 40, 1000);
    CGRect rect = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return rect.size.height;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
